//package com.tiancheng.trade.settlement.util;
//
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.tiancheng.trade.settlement.enums.*;
//import com.tiancheng.trade.settlement.service.settlement.ISRevenueDetailService;
//import com.tiancheng.trade.settlement.util.queue.AbstractCustomQueueConsumer;
//import com.tiancheng.trade.settlement.util.queue.RedisDelayQueueEnum;
//import com.tiancheng.trade.settlement.util.queue.RedisDelayQueueUtil;
//import com.tiancheng.trade.settlement.vo.settlement.api.TallyOrderServiceSuccessVO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.Map;
//import java.util.concurrent.TimeUnit;
//
//@Slf4j
//@Component
//public class OrderSuccessHandle extends AbstractCustomQueueConsumer {
//    @Autowired
//    private ObjectMapper objectMapper;
//    @Resource
//    private JacksonJsonUtil jacksonJsonUtil;
//    @Resource
//    private ISRevenueDetailService isRevenueDetailService;
//    @Resource
//    private RedisDelayQueueUtil redisDelayQueueUtil;
//
//    @Override
//    public void execute(Object params) {
//        try {
//            this.payDataHandle((Map<String, String>) params);
//        } catch (Exception e) {
//            log.error("接收订单服务成功信息异常,", e);
//        }
//    }
//
//    public void pushOrderMessage(Map<String, String> dataMap) {
//        int random=(int)(Math.random()*5+1);
//        redisDelayQueueUtil.addDelayQueue(dataMap, random, TimeUnit.MINUTES, this.getQueueName());
//        log.info("接收订单服务成功信息存入延迟消息队列成功");
//    }
//
//    /**
//     * 支付结果信息推送到神策SDK
//     *
//     * @param dataMap
//     */
//
//    public void payDataHandle(Map<String, String> dataMap) throws Exception {
//        TallyOrderServiceSuccessVO bo = objectMapper.readValue(jacksonJsonUtil.toJson(dataMap.get("data")), new TypeReference<TallyOrderServiceSuccessVO>() {
//        });
//        isRevenueDetailService.subOrderSuccess(bo);
//    }
//
//
//    @Override
//    public String getQueueName() {
//        return RedisDelayQueueEnum.ORDER_SUCCESS_HANDLE_QUEUE.getCode();
//    }
//
//    /**
//     * 轮训时间间隔，单位：s
//     *
//     * @return
//     */
//    @Override
//    public Integer getPullIntervalSeconds() {
//        return RedisDelayQueueEnum.ORDER_SUCCESS_HANDLE_QUEUE.getInterval();
//    }
//}
